﻿using System;
using System.Collections.Generic;
using System.Text;

namespace GMusicBox.Core.Setting
{
    public class FXSetting
    {
        public static Settings Data { get; set; }
        public static string FileName { get { return Settings.SettingSavePath + "\\Config\\Configs\\FX.xml"; } }
        public static void Update() { Data = new Settings(FileName); }
        public static void Save() { Data.WriteAllSettings(FileName); }

        public static void UpdateEqualizer(int index, int value)
        {
            int[] data = (int[])Equalizers.Clone();
            data[index] = value;
            Equalizers = data;
        }

        public static string DspLocation
        {
            get
            {
                string data = Data["DspLocation"];
                if (data == "")
                    return System.Windows.Forms.Application.StartupPath + "\\Plugins";
                else return data;
            }
            set { Data["DspLocation"] = value; }
        }

        public static bool Enabled
        {
            get
            {
                string data = Data["Enabled"];
                if (data == "")
                    return false;
                else return bool.Parse(data);
            }
            set { Data["Enabled"] = value.ToString(); }
        }

        public static string[] EnabledDsp
        {
            get
            {
                string data = Data["EnabledDsp"];
                if (data == "")
                    return new string[0];
                else return data.Split(',');
            }
            set { Data["EnabledDsp"] = Helper.Array2String(value, "|"); }
        }

        public static int[] Equalizers
        {
            get
            {
                string data = Data["Equalizers"];
                if (data == "")
                    return new int[10];
                else return Helper.String2IntArray(data);
            }
            set { Data["Equalizers"] = Helper.Array2String(value, ","); }
        }

        public static double Equilibrium
        {
            get
            {
                string data = Data["Equilibrium"];
                if (data == "")
                    return 0;
                else return double.Parse(data);
            }
            set { Data["Equilibrium"] = value.ToString(); }
        }

        public static int ReverbTime
        {
            get
            {
                string data = Data["ReverbTime"];
                if (data == "")
                    return 0;
                else return int.Parse(data);
            }
            set { Data["ReverbTime"] = value.ToString(); }
        }

        public static int PreampGain
        {
            get
            {
                string data = Data["PreampGain"];
                if (data == "")
                    return 0;
                else return int.Parse(data);
            }
            set { Data["PreampGain"] = value.ToString(); }
        }
    }
}
